home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / sys_api.h < prev    next >
C/C++ Source or Header  |  1998-09-15  |  6KB  |  205 lines

  1. /*
  2.  * @(#)sys_api.h    1.64 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. /*
  16.  * System or Host dependent API.  This defines the "porting layer" for
  17.  * POSIX.1 compliant operating systems.
  18.  */
  19.  
  20. #ifndef _SYS_API_H_
  21. #define _SYS_API_H_
  22.  
  23. /*
  24.  * typedefs_md.h includes basic types for this platform;
  25.  * any macros for HPI functions have been moved to "sysmacros_md.h"
  26.  */
  27. #include "typedefs_md.h"
  28.  
  29. /*
  30.  * Miscellaneous system utility APIs that fall outside the POSIX.1
  31.  * spec.
  32.  *
  33.  * Until POSIX (P1003.1a) formerly P.4 is standard, we'll use our
  34.  * time struct definitions found in timeval.h.
  35.  */
  36. #include "timeval.h"
  37. long     sysGetMilliTicks(void);
  38. long    sysTime(long *);
  39. int64_t sysTimeMillis(void);
  40.  
  41. #include "time.h"
  42. struct tm * sysLocaltime(time_t *, struct tm*);
  43. struct tm * sysGmtime(time_t *, struct tm*);
  44. void        sysStrftime(char *, int, char *, struct tm *);
  45. time_t      sysMktime(struct tm*);
  46.  
  47. /*
  48.  * System API for general allocations
  49.  */
  50. void *    sysMalloc(size_t);
  51. void *    sysRealloc(void*, size_t);
  52. void    sysFree(void*);
  53. void *    sysCalloc(size_t, size_t);
  54. #ifdef PAGED_HEAPS
  55. void *  sysAllocBlock(size_t, void**);
  56. void    sysFreeBlock(void *);
  57. #endif /* PAGED_HEAPS */
  58.  
  59. /*
  60.  * System API for dynamic linking libraries into the interpreter
  61.  */
  62. char *  sysInitializeLinker(void);
  63. int     sysAddDLSegment(char *);
  64. void    sysSaveLDPath(char *);
  65. long    sysDynamicLink(char *);
  66. void    sysBuildLibName(char *, int, char *, char *);
  67. int     sysBuildFunName(char *, int, void *, int);
  68. long *  sysInvokeNative(void *, void *, long *, char *, int, void *);
  69.  
  70. /*
  71.  * System API for invoking the interpreter from native applications
  72.  */
  73. void    sysGetDefaultJavaVMInitArgs(void *);
  74. int     sysInitializeJavaVM(void *, void *);
  75. int     sysFinalizeJavaVM(void *);
  76. void    sysAttachThreadLock();
  77. void    sysAttachThreadUnlock();
  78.  
  79. /*
  80.  * System API for threads
  81.  */
  82. typedef struct  sys_thread sys_thread_t;
  83. typedef struct  sys_mon sys_mon_t;
  84. typedef void *  stackp_t;
  85.  
  86. int     sysThreadBootstrap(sys_thread_t **, void *);
  87. void     sysThreadInitializeSystemThreads(void);
  88. int     sysThreadCreate(long, uint_t flags, void *(*)(void *),
  89.             sys_thread_t **, void *);
  90. void    sysThreadExit(void);
  91. sys_thread_t * sysThreadSelf(void);
  92. void    sysThreadYield(void);
  93. int     sysThreadVMSuspend(sys_thread_t *, sys_thread_t *);
  94. void    sysThreadVMSuspendMe(void);
  95. int     sysThreadVMUnsuspend(sys_thread_t *);
  96. int    sysThreadSuspend(sys_thread_t *);
  97. int    sysThreadResume(sys_thread_t *);
  98. int    sysThreadSetPriority(sys_thread_t *, int);
  99. int    sysThreadGetPriority(sys_thread_t *, int *);
  100. void *  sysThreadStackPointer(sys_thread_t *); 
  101. stackp_t sysThreadStackBase(sys_thread_t *); 
  102. void    sysThreadSetStackBase(sys_thread_t *, stackp_t); 
  103. int    sysThreadSingle(void);
  104. void    sysThreadMulti(void);
  105. int     sysThreadEnumerateOver(int (*)(sys_thread_t *, void *), void *);
  106. void    sysThreadInit(sys_thread_t *, stackp_t);
  107. void *  sysThreadGetBackPtr(sys_thread_t *);
  108. int     sysThreadCheckStack(void);
  109. int     sysInterruptsPending(void);
  110. void    sysThreadPostException(sys_thread_t *, void *);
  111. void    sysThreadDumpInfo(sys_thread_t *);
  112. void    sysThreadInterrupt(sys_thread_t *);
  113. int     sysThreadIsInterrupted(sys_thread_t *, long);
  114. int     sysThreadAlloc(sys_thread_t **, stackp_t, void *);
  115. int     sysThreadFree(sys_thread_t *);
  116.  
  117. /*
  118.  * System API for monitors
  119.  */
  120. int     sysMonitorSizeof(void);
  121. int     sysMonitorInit(sys_mon_t *);
  122. int     sysMonitorDestroy(sys_mon_t *);
  123. int     sysMonitorEnter(sys_mon_t *);
  124. bool_t  sysMonitorEntered(sys_mon_t *);
  125. int     sysMonitorExit(sys_mon_t *);
  126. int     sysMonitorNotify(sys_mon_t *);
  127. int     sysMonitorNotifyAll(sys_mon_t *);
  128. int     sysMonitorWait(sys_mon_t *, int, bool_t);
  129. void    sysMonitorDumpInfo(sys_mon_t *);
  130. bool_t  sysMonitorInUse(sys_mon_t *);
  131.  
  132. #define SYS_OK            0
  133. #define SYS_ERR           -1
  134. #define SYS_INTRPT     -2    /* Operation was interrupted */
  135. #define SYS_TIMEOUT    -3    /* A timer ran out */
  136. #define SYS_NOMEM      -5    /* Ran out of memory */
  137. #define SYS_NORESOURCE -6    /* Ran out of some system resource */
  138.  
  139. /*
  140.  * Symbolic constant to be used when waiting indefinitly on a condition
  141.  * variable
  142.  */
  143. #define SYS_TIMEOUT_INFINITY -1
  144.  
  145. /*
  146.  * System API for raw memory allocation
  147.  */
  148. void *  sysMapMem(long, long *);
  149. void *  sysUnmapMem(void *, long, long *);
  150. void *  sysCommitMem(void *, long, long *);
  151. void *  sysUncommitMem(void *, long, long *);
  152.  
  153. /*
  154.  * System API for termination
  155.  */
  156. void    sysExit(int);
  157. int    sysAtexit(void (*func)(void));
  158. void    sysAbort(void);
  159.  
  160. /*
  161.  * System API for files
  162.  */
  163. extern int sysIsAbsolute(const char* path);
  164. extern int sysAccess(const char* pFile, int perm);
  165.  
  166. extern int sysStat(const char *path, struct stat *sbuf);
  167. extern int sysFStat(int fd, struct stat * sbuf);
  168.  
  169. extern int sysOpen(const char *name, int openMode, int filePerm);
  170. extern int sysClose(int fd);
  171.  
  172. extern long sysSeek(int fd, long offset, int whence);
  173. extern int sysAvailable(int fd, long* bytes);
  174. extern size_t sysRead(int fd, void *buf, unsigned int nBytes);
  175. extern size_t sysWrite(int fd, const void *buf, unsigned int nBytes);
  176.  
  177. extern int sysRename(const char* srcName, const char* dstName);
  178. extern int sysUnlink(const char* file);
  179.  
  180. extern int sysMkdir(const char* path, int mode);
  181. extern int sysRmdir(const char* path);
  182. extern int sysCanonicalPath(char *path, char *result, int result_len);
  183.  
  184. #include "io_md.h"
  185. extern DIR* sysOpenDir(const char* path);
  186. extern int sysCloseDir(DIR* dp);
  187. extern struct dirent* sysReadDir(DIR* dp);
  188.  
  189. /*
  190.  * API support needed for various multiprocessor related syncronization
  191.  * primitives.  Systems that don't use real threads can just define
  192.  * these to be 0 in their sysmacros_md.h.
  193.  */
  194.  
  195. int sysIsMP();
  196. void sysMemoryFlush();
  197. void sysStoreBarrier();
  198.  
  199. /*
  200.  * Include platform specific macros to override these
  201.  */
  202. #include "sysmacros_md.h"
  203.  
  204. #endif /* !_SYS_API_H_ */
  205.